package com.youkeda.service.impl;

import com.youkeda.model.Course;
import com.youkeda.service.CourseService;

import java.util.ArrayList;
import java.util.List;

/**
 * @author xshuai
 */
public class CourseServiceImpl implements CourseService {
    private static List<Course> courses;

    @Override
    public void add(Course course) {
        if (courses == null) {
            courses = new ArrayList<>();
        }
        courses.add(course);
    }

    @Override
    public Course get(String courseId) {
        for (Course c : courses) {
            if (c.getId().equals(courseId)) {
                return c;
            }
        }
        return null;
    }
}
